package com.hfjava.ebook.controller;

import com.hfjava.ebook.common.JsonResult;
import com.hfjava.ebook.entity.Category;
import com.hfjava.ebook.server.CategoryService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping("/category")
@RestController
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    @RequestMapping("/{id}/detail")
    public JsonResult<Category> getCategoryOnly(@PathVariable int id){
        Category category = categoryService.findCategoryById(id);
        return JsonResult.ok(category);
    }
}
